<template>
  <div class="goodsmanage">
    <div class="goods-list">
      <template v-for="goods in goodslist" :key="goods.id">
	<GoodsEdit
	  :id       =    "goods.id"
	  :name     =    "goods.name"
	  :price    =    "goods.price"
	  :stock    =    "goods.stock"
	  :typename =    "goods.typename"
	  :typeid   =    "goods.typeid"
	  :tokendown=    "goods.tokendown"
	  :desc     =    "goods.desc"
	  :filename =    "goods.filename"
	  :base64   =    "goods.base64"/>

      </template>
    </div>
  </div>
</template>

<script lang="ts" setup>
 import { findAllGoods, findAllTypes } from '@/service';
 import { onBeforeMount, provide, ref } from 'vue';
 import {GoodsEdit} from '@/components/Goods/';

 const goodslist = ref<Goods []>([])
 const goodstypes = ref<GoodsType []>([])

 provide('GoodsTypes', goodstypes)

 onBeforeMount(async () => {
   let response = await findAllGoods({})
   goodslist.value = response.data

   response = await findAllTypes()
   goodstypes.value = response.data

 })

</script>

<style lang="scss" scoped>
 div.goods-list {
   display: grid;
   grid-template-columns: repeat(2, 50%);
 }
</style>